package com.xiao.community.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiao.group.common.utils.PageUtils;
import com.xiao.group.common.utils.Query;

import com.xiao.community.dao.QianUserDao;
import com.xiao.community.entity.QianUserEntity;
import com.xiao.community.service.QianUserService;


@Service("qianUserService")
public class QianUserServiceImpl extends ServiceImpl<QianUserDao, QianUserEntity> implements QianUserService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<QianUserEntity> page = this.page(
                new Query<QianUserEntity>().getPage(params),
                new QueryWrapper<QianUserEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public QianUserEntity login(QianUserEntity qianUserEntity) {
        QueryWrapper<QianUserEntity> queryWrapper = new QueryWrapper<>();
        QueryWrapper<QianUserEntity> eq = queryWrapper.eq("user_name", qianUserEntity.getUserName()).eq("user_pwd", qianUserEntity.getUserPwd());
        return baseMapper.selectOne(eq);
    }

    @Override
    public QianUserEntity selectUid(Integer userId) {

        return baseMapper.selectOne(new QueryWrapper<QianUserEntity>().eq("user_id",userId));
    }

}